<template>
<!-- 新闻列表组件 -->
<div>
  <ul class="mui-table-view">
      <li class="mui-table-view-cell" v-for="item in newList" :key="item.id">
        <router-link :to="'/news/info/'+item.id">
          <img :src="item.img_url" alt="" class="mui-media-object mui-pull-left">  
          <div>
            <h3>{{item.title}}</h3>
            <p class="mui-ellipsis">
              <span>时间: {{item.add_time | timeFormat}}</span>
              <span>点击: {{item.click}}</span>
            </p>
          </div>
        </router-link>
      </li>    
	</ul>
</div>
</template>
<script>
import { Toast } from "mint-ui";

export default {
  data() {
    return {
      newList: []
    };
  },
  // 函数调用
  created() {
    this.getNewsList();
  },
  methods: {
    getNewsList() {
      this.$http.get("api/getnewslist").then(res => {
        console.log(res.body);
        if (res.body.status === 0) {
          this.newList = res.body.message;
        } else {
          Toast("新闻列表加载失败");
        }
      });
    }
  }
};
</script>
<style scoped lang="less">
.mui-table-view {
  h3 {
    font-size: 14px;
  }
  .mui-ellipsis {
    display: flex;
    color: #26a2ff;
    justify-content: space-between;
    font-size: 12px;
  }
}
</style>